package com.uls.web.controller.zsw;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uls.common.annotation.Log;
import com.uls.common.core.controller.BaseController;
import com.uls.common.core.domain.AjaxResult;
import com.uls.common.enums.BusinessType;
import com.uls.zsw.domain.DormitoryCheck;
import com.uls.zsw.service.IDormitoryCheckService;
import com.uls.common.utils.poi.ExcelUtil;
import com.uls.common.core.page.TableDataInfo;

/**
 * 宿舍查寝Controller
 * 
 * @author zsw
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/zsw/check")
public class DormitoryCheckController extends BaseController
{
    @Autowired
    private IDormitoryCheckService dormitoryCheckService;

    /**
     * 查询宿舍查寝列表
     */
    @PreAuthorize("@ss.hasPermi('zsw:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(DormitoryCheck dormitoryCheck)
    {
        startPage();
        List<DormitoryCheck> list = dormitoryCheckService.selectDormitoryCheckList(dormitoryCheck);
        return getDataTable(list);
    }

    /**
     * 导出宿舍查寝列表
     */
    @PreAuthorize("@ss.hasPermi('zsw:check:export')")
    @Log(title = "宿舍查寝", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DormitoryCheck dormitoryCheck)
    {
        List<DormitoryCheck> list = dormitoryCheckService.selectDormitoryCheckList(dormitoryCheck);
        ExcelUtil<DormitoryCheck> util = new ExcelUtil<DormitoryCheck>(DormitoryCheck.class);
        util.exportExcel(response, list, "宿舍查寝数据");
    }

    /**
     * 获取宿舍查寝详细信息
     */
    @PreAuthorize("@ss.hasPermi('zsw:check:query')")
    @GetMapping(value = "/{dormtoryCheckId}")
    public AjaxResult getInfo(@PathVariable("dormtoryCheckId") Long dormtoryCheckId)
    {
        return success(dormitoryCheckService.selectDormitoryCheckByDormtoryCheckId(dormtoryCheckId));
    }

    /**
     * 新增宿舍查寝
     */
    @PreAuthorize("@ss.hasPermi('zsw:check:add')")
    @Log(title = "宿舍查寝", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DormitoryCheck dormitoryCheck)
    {
        return toAjax(dormitoryCheckService.insertDormitoryCheck(dormitoryCheck));
    }

    /**
     * 修改宿舍查寝
     */
    @PreAuthorize("@ss.hasPermi('zsw:check:edit')")
    @Log(title = "宿舍查寝", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DormitoryCheck dormitoryCheck)
    {
        return toAjax(dormitoryCheckService.updateDormitoryCheck(dormitoryCheck));
    }

    /**
     * 删除宿舍查寝
     */
    @PreAuthorize("@ss.hasPermi('zsw:check:remove')")
    @Log(title = "宿舍查寝", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dormtoryCheckIds}")
    public AjaxResult remove(@PathVariable Long[] dormtoryCheckIds)
    {
        return toAjax(dormitoryCheckService.deleteDormitoryCheckByDormtoryCheckIds(dormtoryCheckIds));
    }
}
